import { Body, Controller, Get, Post, Req, UseGuards } from '@nestjs/common';
import { AuthorBaseControll } from '../controllers/authorBase.controller';
import { Request } from 'express';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { OrderCreateDto } from '../dtos/order.dto';
import { OrderService } from '../services/order.serve';
import { AuthorityService } from '../services/authority.service';
import { AuthGuard } from '../guards/authority.guard';

@UseGuards(AuthGuard)
@Controller('/order')
@ApiTags('订单接口')
export class OrderController extends AuthorBaseControll {
  constructor(
    private readonly OrderService: OrderService,
    private readonly authorityService: AuthorityService,
  ) {
    super();
  }

  @Post('/createOrder')
  @ApiOperation({ summary: '创建订单' })
  async createOrderPay(
    @Body() createOrderField: OrderCreateDto,
    @Req() request: Request,
  ) {
    const userInfo = await this.authorityService.verify(
      request?.headers?.token,
    );
    return this.OrderService.createOrderpayService(
      createOrderField,
      userInfo.id,
    );
  }

  @Get('/orderList')
  @ApiOperation({ summary: '订单列表' })
  async getOrderList() {}
}
